package com.he.swing1;

import javax.swing.*;
import java.awt.*;

/**
 * @description: JavaSwing_1_FlowLayout 流式布局
 * @author: ShouSi
 * @createDate: 2021/11/1
 * @address: https://www.cnblogs.com/xxhxs-21/p/15493987.html
 */
public class JavaSwing_1_FlowLayout {

	public static void main(String[] args) {
		JFrame jf = new JFrame("测试窗口");
		jf.setSize(400,450);
		jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		jf.setLocationRelativeTo(null);

		// 创建内容面板，指定使用流式布局
		JPanel panel = new JPanel(new FlowLayout());

		JButton btn01 = new JButton("按钮01");
		JButton btn02 = new JButton("按钮02");
		JButton btn03 = new JButton("按钮03");
		JButton btn04 = new JButton("按钮04");
		JButton btn05 = new JButton("按钮05");

		panel.add(btn01);
		panel.add(btn02);
		panel.add(btn03);
		panel.add(btn04);
		panel.add(btn05);

		jf.setContentPane(panel);
		jf.setVisible(true);        // PS: 最后再设置为可显示(绘制), 所有添加的组件才会显示
	}
}
